package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.bean.FeedRecommendItemBean;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityProtocol;
import com.huawei.appgallery.forum.user.api.IUserFollow;
import com.huawei.appgallery.forum.user.api.IUserFollow.b;
import com.huawei.appgallery.forum.user.api.IUserHomePageProtocol;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwTextView;
import o.bqy;
import o.brd;
import o.bst;
import o.bsv;
import o.bsx;
import o.bsy.c;
import o.bsy.d;
import o.bsy.h;
import o.bsy.j;
import o.bwx;
import o.cgz;
import o.cil;
import o.cim.a;
import o.eqx;
import o.evf;
import o.evx;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjo;
import o.fjq;
import o.fjt;

public class ForumFeedRecommendItemCard extends ForumCard {
    private int ʻ = 0;
    private HwTextView ˊ;
    private ImageView ˋ;
    private HwTextView ˎ;
    private HwTextView ˏ;
    private ImageView ॱ;
    private FeedRecommendItemBean ॱॱ;

    public ForumFeedRecommendItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ˋ = (ImageView) view.findViewById(c.ʽॱ);
        this.ॱ = (ImageView) view.findViewById(c.ʿ);
        this.ˎ = (HwTextView) view.findViewById(c.ॱˎ);
        this.ˊ = (HwTextView) view.findViewById(c.ʼॱ);
        this.ˏ = (HwTextView) view.findViewById(c.ﹳ);
        this.ˋ.setOnClickListener(new evx(this) {
            final /* synthetic */ ForumFeedRecommendItemCard ˏ;

            {
                this.ˏ = r1;
            }

            public void ˋ(View view) {
                this.ˏ.ˏॱ();
            }
        });
        this.ॱ.setOnClickListener(new evx(this) {
            final /* synthetic */ ForumFeedRecommendItemCard ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                this.ˊ.ˊॱ();
            }
        });
        this.ˏ.setOnClickListener(new evx(this) {
            final /* synthetic */ ForumFeedRecommendItemCard ॱ;

            {
                this.ॱ = r1;
            }

            public void ˋ(View view) {
                this.ॱ.ॱॱ();
            }
        });
        view.setOnClickListener(new evx(this) {
            final /* synthetic */ ForumFeedRecommendItemCard ˋ;

            {
                this.ˋ = r1;
            }

            public void ˋ(View view) {
                if (this.ˋ.ॱॱ == null) {
                    return;
                }
                if (this.ˋ.ॱॱ.ᐝ() == 1) {
                    this.ˋ.ˏॱ();
                } else if (this.ˋ.ॱॱ.ᐝ() == 0) {
                    this.ˋ.ˊॱ();
                }
            }
        });
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof FeedRecommendItemBean) {
            this.ॱॱ = (FeedRecommendItemBean) cardBean;
            if (1 == this.ॱॱ.ᐝ()) {
                ᐝ();
            } else {
                ʼ();
            }
        }
    }

    private void ᐝ() {
        String ˏ;
        String str = null;
        this.ॱ.setVisibility(8);
        this.ˋ.setVisibility(0);
        Section ˊ = this.ॱॱ.ˊ();
        long j = 0;
        if (ˊ != null) {
            ˏ = ˊ.ˏ();
            str = ˊ.ॱ();
            j = ˊ.ˎ();
            this.ʻ = ˊ.ᐝ();
        } else {
            ˏ = null;
        }
        eqx.ˏ(this.ˋ, str, "app_default_icon");
        ˎ(this.ˎ, ˏ);
        str = bst.ॱ(this.ʼॱ, j);
        ˎ(this.ˊ, this.ʼॱ.getResources().getQuantityString(h.ˋ, Long.valueOf(j).intValue(), new Object[]{str}));
        ʽ();
    }

    private void ʼ() {
        String ˎ;
        String ˋ;
        String str = null;
        this.ॱ.setVisibility(0);
        this.ˋ.setVisibility(8);
        User ˎ2 = this.ॱॱ.ˎ();
        if (ˎ2 != null) {
            ˎ = ˎ2.ˎ();
            ˋ = ˎ2.ˋ();
            this.ʻ = ˎ2.ʻॱ();
        } else {
            ˋ = null;
            ˎ = null;
        }
        Section ˊ = this.ॱॱ.ˊ();
        if (ˊ != null) {
            if (!TextUtils.isEmpty(ˊ.ˏ())) {
                str = this.ʼॱ.getResources().getString(j.ˋ, new Object[]{r3});
            }
        }
        bsx.ˋ(this.ʼॱ, this.ॱ, ˎ);
        ˎ(this.ˎ, ˋ);
        ˎ(this.ˊ, str);
        ʻ();
    }

    private void ˎ(HwTextView hwTextView, String str) {
        if (TextUtils.isEmpty(str)) {
            hwTextView.setText("");
        } else {
            hwTextView.setText(str);
        }
    }

    private void ʽ() {
        if (1 == this.ʻ) {
            ˎ(j.ॱॱ, d.ˋ);
        } else {
            ˎ(j.ॱˊ, d.ॱ);
        }
    }

    private void ʻ() {
        if (this.ʻ == 1) {
            ˎ(j.ॱॱ, d.ˋ);
        } else if (this.ʻ == 0) {
            ˎ(j.ॱˊ, d.ॱ);
        } else if (this.ʻ == 2) {
            ˎ(j.ʻ, d.ˋ);
        }
    }

    private void ˎ(int i, int i2) {
        this.ˏ.setText(i);
        this.ˏ.setTextColor(evf.ॱ(this.ʼॱ, i2));
    }

    private void ॱॱ() {
        if (this.ॱॱ != null) {
            if (1 == this.ॱॱ.ᐝ()) {
                ˎ();
            } else {
                ͺ();
            }
        }
    }

    private void ͺ() {
        if (this.ॱॱ.ˎ() != null) {
            int i;
            final User ˎ = this.ॱॱ.ˎ();
            if (ˎ.ʻॱ() == 0) {
                i = 0;
            } else {
                i = 1;
            }
            ((IUserFollow) fho.ˏ().ˋ("User").ॱ(IUserFollow.class)).ॱ(this.ʼॱ, ˎ, i).ˋ(fjt.ˎ(), new fjq<b>(this) {
                final /* synthetic */ ForumFeedRecommendItemCard ˏ;

                public void onComplete(fjo<b> o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
                    b bVar = (b) o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ();
                    if (o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ˊ() && bVar.ˏ() == 0) {
                        this.ˏ.ʻ = bVar.ˋ();
                        ˎ.ˎ(bVar.ˋ());
                        this.ˏ.ʻ();
                        brd.ॱ.ˋ(bqy.ˋ().ˎ(this.ˏ.ʼॱ), bqy.ˋ().ˎ(), this.ˏ.ॱॱ.ॱˈ(), "RECOMMEND", i == 0 ? 1 : 0);
                    }
                }
            });
        }
    }

    public void ˎ() {
        if (this.ॱॱ.ˊ() != null) {
            int i = 0;
            if (1 == this.ʻ) {
                i = 1;
            }
            ((bwx) fho.ˏ().ˋ("Operation").ॱ(bwx.class)).ˏ(this.ʼॱ, this.ॱॱ.ˊ(), i, bsv.ॱ(this.ॱॱ.ॱ()).ˎ()).ˏ(new fjq<Boolean>(this) {
                final /* synthetic */ ForumFeedRecommendItemCard ˎ;

                public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                    if (!o_fjo_java_lang_Boolean.ˊ() || !((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                        return;
                    }
                    if (i == 0) {
                        this.ˎ.ॱॱ.ˊ().ˊ(1);
                        this.ˎ.ʻ = 1;
                        this.ˎ.ʽ();
                        return;
                    }
                    this.ˎ.ॱॱ.ˊ().ˊ(0);
                    this.ˎ.ʻ = 0;
                    this.ˎ.ʽ();
                }
            });
        }
    }

    private void ˊॱ() {
        if (this.ॱॱ != null && this.ॱॱ.ˎ() != null) {
            fjb ˎ = fho.ˏ().ˋ("User").ˎ("UserHomePageActivity");
            IUserHomePageProtocol iUserHomePageProtocol = (IUserHomePageProtocol) ˎ.ˊ();
            iUserHomePageProtocol.setUri("forum|user_detail_topic");
            iUserHomePageProtocol.setUserId(this.ॱॱ.ˎ().ॱ());
            iUserHomePageProtocol.setType(this.ॱॱ.ˎ().ˊ());
            iUserHomePageProtocol.setDomainId(this.ॱॱ.ॱ());
            fiu.ˊ().ˏ(this.ʼॱ, ˎ);
        }
    }

    private void ˏॱ() {
        if (this.ॱॱ != null && this.ॱॱ.ˊ() != null) {
            cil.ˋ(this.ʼॱ, new a(this.ॱॱ).ˊ(this.ॱॱ.ˊ().ॱॱ()).ˋ());
            fjb ˎ = fho.ˏ().ˋ("Section").ˎ("section_detail_activity");
            ((ISectionDetailActivityProtocol) ˎ.ˊ()).setUri(this.ॱॱ.ˊ().ॱॱ());
            fiu.ˊ().ˏ(this.ʼॱ, ˎ);
        }
    }
}
